/*
 * @Author: 9ilk 3535851673@qq.com
 * @Date: 2024-11-05 16:57:32
 * @LastEditors: 9ilk 3535851673@qq.com
 * @LastEditTime: 2024-11-05 22:45:49
 * @FilePath: /zhuang/namePipe/Client.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include"Comm.hpp"
using namespace std;

class Client
{
public:
    Client()
        : _fd(gdeafultfd)
    {}
    // 打开管道
    bool OpenPipe()
    {
        _fd = ::open(gpipefile.c_str(), O_WRONLY);
        if (_fd < 0)
        {
            cerr << "open fail" << endl;
            return false;
        }
        return true; 
    }

    // 向管道发
    int SendPipe(const string& in)
    {
        return ::write(_fd,in.c_str(),in.size());
    }

    // 关闭管道
    void ClosePipe()
    {
        if (_fd >= 0)
            ::close(_fd);
    }

    ~Client()
    {}

private:
    int _fd;
};